<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body {
            margin: 0;
            height: 1300px;
        }

        .nav {
            width: 100%;
            height: 50px;
            border-bottom: 1px solid #666;
        }

        .nav .body {
            width: 850px;
            /* background-color: red; */
            display: flex;
            justify-content: space-between;
            float: right;
        }

        a {
            color: black;
            line-height: 50px;
        }

        .sou {

            text-align: center;
        }



        .sou .zhu {
            width: 1100px;
            margin: 0 auto;
        }

        .sou img {
            width: 120px;
            height: 70px;
            position: relative;
            top: 10px;
        }

        .sou input {
            width: 600px;
            height: 30px;
            margin-top: -100px;
        }

        .sou button {
            background-color: #3388ff;
            font-size: 20px;
            color: white;
        }

        .main {
            width: 100%;
            height: 60px;
            background-color: #01204f;
        }

        .main .er {
            width: 1200px;
            height: 60px;
            /* background-color: lightcoral; */
            margin: 0 auto;
        }

        .main ul {
            width: 900px;
            list-style: none;
            display: flex;
            justify-content: space-between;
        }

        .main ul li {
            line-height: 60px;
            color: white;
        }

        .main ul li:nth-child(1) {
            background-color: red;
            width: 50px;
            height: 60px;
        }

        .main ul .active {
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="nav">
        <div class="body">
            <a href="#">网页</a>
            <a href="#">新闻</a>
            <a href="#">贴吧</a>
            <a href="#">知道</a>
            <a href="#">音乐</a>
            <a href="#">图片</a>
            <a href="#">视屏</a>
            <a href="#">地图</a>
            <a href="#">文库</a>
            <a href="#">百度首页</a>
            <a href="#">登录</a>
            <a href="#">注册</a>
            <a href="#">客户端</a>

        </div>
    </div>
    <div class="sou">

        <div class="zhu">
            <img src="dsa.png" alt="baidu">
            <input type="text">
            <button type="text">百度一下</button> &#x3000;
            <a href="#">帮助</a> &#x3000;
            <a href="#">高级搜索</a> &#x3000;
            <a href="#">设置</a>

        </div>

    </div>
    <div class="main">
        <div class="er">
            <ul>
                <li class="active">首页</li>
                <li>百家好</li>
                <li>国内</li>
                <li>国际</li>
                <li>局势</li>
                <li>军事</li>
                <li>社会</li>
                <li>财经</li>
                <li>娱乐</li>
                <li>体育</li>
                <li>科技</li>
                <li>游戏</li>
                <li>时尚</li>
                <li>女人</li>
                <li>汽车</li>
                <li>个性</li>
                <li>更多</li>
            </ul>
        </div>
    </div>

</body>

</html>
<script>
    var lis = document.querySelectorAll('.main ul li')
    var main = document.querySelector('.main');
    window.onscroll = function () {
        var scrollTop = document.scrollingElement.scrollTop
        if (scrollTop >= 153) {
            main.style.position = 'fixed';
            main.style.top = '0';
        }
        else {

            main.style.cssText = '';



        }
    }

    for (var i = 0; i < lis.length; i++) {
        lis[i].onmouseover = function () {

            for (var i = 0; i < lis.length; i++) {
                lis[i].className = '';
            }

            this.className = 'active';
        }
        lis[i].onmouseout = function () {
            for (var i = 0; i < lis.length; i++) {
                lis[i].className = '';
            }
        }
    }

</script>